package org.md.budzik.problems;

import java.math.BigInteger;
import java.util.Map;

/**
 * Abstrakt działania jednoargumentowego.
 * @author Wiezzel
 *
 */
public abstract class OneArgOp extends Expression {
	
	protected Expression argument;
	protected abstract BigInteger computeOperation(BigInteger value) throws ParseException;	
	protected abstract String operationSymbol();

	public String toString() {
		return argument.toString() + " " + operationSymbol();
	}
	
	public BigInteger value(Map<String,Integer> variables) throws ParseException {
//		System.out.println(this + " = " + computeOperation(argument.value(variables)));
		return computeOperation(argument.value(variables));
	}
	
	public OneArgOp(Expression ex) {
		this.argument = ex;
	}

}